# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=cffi
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.14.4
pkgrel=1
pkgdesc="Foreign Function Interface for Python calling C code (mingw-w64)"
url='https://cffi.readthedocs.io/'
license=('MIT')
arch=('any')
depends=("${MINGW_PACKAGE_PREFIX}-libffi"
         "${MINGW_PACKAGE_PREFIX}-python-pycparser")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest-runner")
source=("https://foss.heptapod.net/pypy/cffi/-/archive/v${pkgver}/${_realname}-v${pkgver}.tar.bz2")
sha256sums=('767124ff1a55c8433558253ac06d2777878452cdb43710f308acf0d2ca479e56')

prepare() {
  cd "${srcdir}"
  cp -r "${_realname}-v${pkgver}" "python-build-${CARCH}"
}

build() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --skip-build

  install -D -m644 LICENSE "${pkgdir}${MINGW_PREFIX}"/share/licenses/python-${_realname}/LICENSE
}
